package com.sentrix.auto.printercenter.infrastructure.config;

import com.sentrix.auto.printercenter.presentation.common.BaseResponse;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.UUID;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public BaseResponse handleException(HttpServletRequest request, Exception e) {
        log.error("系统异常，地址：{}，信息：{}", request.getRequestURI(), e.getMessage());
        return new BaseResponse(UUID.randomUUID().toString(), false, 500, e.getMessage());
    }
}
